<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>{$current['title']}-{$Think.CONFIG.sitename}</title>

    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <!-- Sweet Alert -->
    <link href="__PUBLIC__/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>

<body class="gray-bg top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <include file="Public/header" />
        </div>
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-3">
                    <div class="ibox float-e-margins">
                        <include file="Public/setnav" />
                    </div>
                </div>
                <div class="col-sm-9 animated fadeInRight">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title"><h4>所有用户组</h4></div>
                        <div class="ibox-content">

                            <div class="row row-lg">


                                <div class="col-sm-12">
                                    <!-- Example Toolbar -->
                                    <div class="example-wrap">
                                        <!--<h4 class="example-title">工具条</h4>-->
                                        <div class="example">

                                            <div class="bootstrap-table">
                                                <div class="fixed-table-toolbar">
                                                    <div class="bars pull-left">
                                                        <div class="btn-group hidden-xs" id="exampleToolbar" role="group">
                                                            <button type="button" class="btn btn-outline btn-default" onclick="window.location.href='{:U(add)}'">
                                                                <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                                                            </button>
                                                            <button type="button" class="btn btn-outline btn-default" data-toggle="modal" data-target="#delModal" id="get-ids">
                                                                <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
                                                            </button>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="fixed-table-container" style="padding-bottom: 0px;">

                                                    <div class="fixed-table-body">
                                                        <table id="exampleTableToolbar" data-mobile-responsive="true" class="table table-hover">
                                                            <thead>
                                                            <tr>
                                                                <th style="" data-field="name" tabindex="0">
                                                                    <div class="th-inner ">
                                                                        <input type="checkbox" class="check-all">全选
                                                                    </div>
                                                                    <div class="fht-cell">
                                                                    </div>
                                                                </th>
                                                                <th style="" data-field="star" tabindex="0">
                                                                    <div class="th-inner ">
                                                                        名称
                                                                    </div>
                                                                    <div class="fht-cell">
                                                                    </div>
                                                                </th>
                                                                <th style="" data-field="license" tabindex="0">
                                                                    <div class="th-inner ">
                                                                        状态
                                                                    </div>
                                                                    <div class="fht-cell">
                                                                    </div>
                                                                </th>
                                                                <th style="" data-field="license" tabindex="0">
                                                                    <div class="th-inner ">
                                                                        操作
                                                                    </div>
                                                                    <div class="fht-cell">
                                                                    </div>
                                                                </th>

                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            <empty name="list">
                                                                <tr class="no-records-found">
                                                                    <td colspan="4">
                                                                        没有找到匹配的记录
                                                                    </td>
                                                                </tr>
                                                            </empty>
                                                            <notempty name="list">
                                                                <volist name="list" id="val">
                                                                    <tr>
                                                                        <td class="center">
                                                                            <if condition="$val['id'] neq 1"><input class="ids" type="checkbox" name="id[]" value="{$val['id']}"><else /><span title="系统用户组，禁止删除">--</span></if>
                                                                        </td>
                                                                        <td>{$val['title']}</td>
                                                                        <if condition="$val['id'] neq 1">
                                                                            <td><if condition="$val['status'] eq 1"><a href="javascript:;" title="点击禁用" val="{$val['id']}" class="is-stu">启用</a><else /><a href="javascript:;" title="点击启用" val="{$val['id']}" class="is-stu">禁用</a></if></td>
                                                                        <else/>
                                                                            <td><a href="javascript:;" >系统用户禁止操作</a></td>
                                                                        </if>
                                                                        <td class="center"><a href="{:U('edit')}?id={$val['id']}" >修改</a></td>
                                                                    </tr>
                                                                </volist>
                                                            </notempty>
                                                            </tbody>
                                                        </table>
                                                    </div>

                                                </div>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                    </div>
                                    <!-- End Example Toolbar -->
                                </div>


                            </div>


                        </div>
                    </div>

                </div>
            </div>
        </div>
        <!--删除提示模态框-->
        <div class="modal inmodal fade" id="delModal" tabindex="-1" role="dialog"  aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <form action="{:U('del')}" role="form" id="delForm">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title">友情提示</h4>
                        </div>
                        <div class="modal-body">
                            <p id="delTips">确定删除这些用户组吗？</p>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" name="ids" id="del-ids" value="">
                            <button type="button" class="btn btn-white" data-dismiss="modal">让我想想</button>
                            <button type="submit" class="btn btn-danger btn-sm"> 是的！ </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!--状态提示模态框-->

        <include file="Public/footer" />
    </div>
</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/static/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="__PUBLIC__/static/js/plugins/validate/Validform_v5.3.2.js"></script>
<script src="__PUBLIC__/static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
    (function($) {
        //全选按钮
        $(".check-all").click(function () {
            $(".ids").prop("checked", this.checked);
        });

        //获取ids的json数组
        $("#get-ids").click(function(){
            var data = getJson('id[]');
            $("#del-ids").val(data);
        })

        //状态提交
        $('.is-stu').click(function () {
            var stuid= $(this).attr("val");
            var stu= $(this).html();
            var molTitle;
            var molText;
            if(stu =='启用'){
                molTitle = '您确定要禁止这个用户组吗？';
                molText  = '禁用后部分用户可能无法访问系统！';
            }else{
                molTitle = '您确定要启用这个用户组吗？';
                molText  = '启用后用户将可以访问！';
            }
            swal({
                title: molTitle,
                text: molText,
                type: "info",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                cancelButtonText:"取消",
                confirmButtonText: "确定",
                closeOnConfirm: false
            }, function () {
                $.post("{:U('stu')}",{gid:stuid},function(data){
                    if(data.status !== 'y'){
                        swal('操作失败!', "参数错误原因可能是程序没有获取到参数！", "warning");
                    }else{
                        window.location.reload();
                    }
                });
            });
        });

        //删除
        $("#delForm").Validform({
            tiptype:function(msg,o,cssctl){
                if(!o.obj.is("form")){
                    var objtip=o.obj.find("#delTips");
                    cssctl(objtip,o.type);
                    objtip.text(msg);
                }else{
                    if(msg == '恭喜操作成功！'){
                        window.location.reload();
                    }else{
                        var objtip=o.obj.find("#delTips");
                        cssctl(objtip,o.type);
                        objtip.text(msg);
                    }
                }
            },
            ajaxPost:true
        });

    })(jQuery);
</script>
</body>

</html>